#pragma once
#include <Eigen/Eigen>
#include <unordered_set>
#include <Open3D/geometry/KDTreeFlann.h>
#include <Open3D/geometry/Geometry.h>
#include <Open3D/Open3D.h>
class DBSCAN
{
public:
	using EVec = std::vector< Eigen::Vector3d>;
	struct Para
	{
		double _radius{ 0.2 };
		int _min_size{ 4 };
		Para(double radius=0.1,int min_size=4):_radius(radius),_min_size(min_size) {

		}
	};
public:
	DBSCAN(Para para = Para()) :_para(para) {}

	std::vector<std::vector<int>> fit(const EVec& points);

private:
	std::vector<int> findPoints(
		std::unordered_map<int, std::vector<int>>& core,
	std::unordered_map<int, std::vector<int>>& un_core,
	int search_index);


	std::unordered_set<unsigned int> _res;
private:
	Para _para;
};